<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="pub/top_list2.jsp"%>
<style>
#ajax{
	width: 94%;
    margin: 5% 3%;
    display: block;
    padding: 4% 0;
    background-color: #db3752;
    color: #fff;
    text-align: center;
    font-size: 1.7em;
    border-radius: 0.3em;
    border: none;
}
</style>
<style>
 	function submit1(){
 		var userid=jQuery("input[name='UserID']").val();
 		var pass=jQuery("input[name='Password']").val();
 		var captcha=jQuery("input[name='captcha']").val();
 		if(pass&&userid&&captcha)
 	 	 document.forms[0].submit();
 	 	 else
 	 	 alert('输入项不能为空！')
 	}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$("#ajax").mousedown(function(){
		ajax();
	});
});
function ajax(){
	 
	var userid=$("#userid").val();
	var password=$("#password").val();
	
	$.ajax({
		type:"post",
		url:"loginAjax.jsp",
		dataType:"text",
		async : false,
		cache : false,
		data:"userid="+userid+"&password="+password,
		xhrFields: {
	           withCredentials: true
	       },
	    crossDomain: true,
		success:function(d){
			if(d=="fail"){
				alert("您的账号或密码错误，请重新登录");
				qingkong();
			}else {
				alert("登录成功");					
				window.location.href="self.jsp";			
			}		
		},
		error:function(e){
			console.log(e)
		}
	});
}

function qingkong(){
	document.getElementById("userid").value="";	
	document.getElementById("password").value=""; 
}
</script>


<body>
	<header class="top-header">
		<a class="text texta" href="index.jsp">取消</a>
		<h3>登录</h3>
		<a class="text" href="sign.jsp">注册</a>
	</header>

	<div class="login">
		<form method=POST action="">
			
			<ul>
				<li><img src="images/login.png" /> <label>账号</label> <input
					type="text" name="userid" id="userid" placeholder="请输入账号" /></li>
				<li><img src="images/password.png" /> <label>密码</label> <input
					type="password" name="password" id="password" placeholder="请输入密码" /></li>
			</ul>
 
			<input type="button" id="ajax" value="登录" />
		</form>
	</div>

</body>
</html>